<template>
  <div class="tabsitem" @click="xxx" :class="{active,activebottom}">
    <slot></slot>
  </div>
</template>

<script>
export default {
  name: "GuluTabsItem",
  inject: ["eventBus"],
  data() {
    return {
      active: false,
      activebottom:false
    };
  },
  props: {
    name: {
      type: String,
      required: true,
    },
  },
  created() {
    this.eventBus.$on("update:selected", (name) => {
      if (name === this.name) {
        this.active = true;
        this.activebottom = true
      } else {
        this.active = false;
        this.activebottom = false
      }
    });
  },
  methods: {
    xxx() {
      this.eventBus.$emit("update:selected", this.name);
    },
  },
};
</script>

<style lang="scss" scoped>
.tabsitem {
  flex-shrink: 0;
  padding: 0 2em;
  cursor: pointer;
  height: 100%;
  display: flex;
    justify-content: flex-start;
  &.active {
    color:#3eaf7c;
    font-weight: bold;
  }
  &.activebottom{
      border-bottom: 2px solid #3eaf7c;
  }
}
</style>